package com.usian.controller;

import com.usian.feign.SearchFeign;
import com.usian.pojo.SerachItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("frontend/searchItem")
@RestController
public class SearchController {

    @Autowired
    private SearchFeign searchFeign;

    @RequestMapping("importAll")
    public  boolean  importAll(){
        return searchFeign.importAll();
    }

    /**
     * 首页搜索
     *
     * @param q
     * @param page
     * @param pageSize
     * @return
     */
    @RequestMapping("list")
    public List<SerachItem> list(@RequestParam String q,
                                 @RequestParam(defaultValue = "1") Long page,
                                 @RequestParam(defaultValue = "10") Long pageSize){
        List<SerachItem> list = searchFeign.list(q, page, pageSize);

        return list;
    }
}
